package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.GoodsComment;
import com.micro.modual.extension.GoodsCommentExtension;
import com.micro.modual.mapper.GoodsCommentMapper;
import com.micro.modual.model.bo.goodscomment.GoodsCommentBO;
import com.micro.modual.service.GoodsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>商品评论表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("goodsCommentService")
public class GoodsCommentServiceImpl extends AbstractBasicsServiceImpl<GoodsComment,Long> implements GoodsCommentService {

    @Autowired
    private GoodsCommentMapper goodsCommentMapper;

    /**
     * <h2>新增商品评论表详情</h2>
     * @param goodsCommentBO {@link GoodsCommentBO} 商品评论表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addGoodsComment(GoodsCommentBO goodsCommentBO) {
        GoodsComment goodsComment = GoodsCommentExtension.converAddGoodsComment(goodsCommentBO);
        goodsCommentMapper.insertSelective(goodsComment);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改商品评论表详情</h2>
     * @param goodsCommentBO  {@link GoodsCommentBO} 商品评论表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editGoodsComment(GoodsCommentBO goodsCommentBO) {
        GoodsComment goodsComment = GoodsCommentExtension.converEditGoodsComment(goodsCommentBO);
        goodsCommentMapper.updateByPrimaryKeySelective(goodsComment);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除商品评论表信息</h2>
     * @param id  商品评论表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteGoodsComment(Long id) {
        goodsCommentMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
